package com.nurun.cacheimageloader;

import android.widget.ImageView;

import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader;

public class VolleyImageLoader extends ImageLoader {

    public VolleyImageLoader(RequestQueue queue) {
        super(queue, new LruBitmapCache(50 * 1024 * 1024));
    }

    public ImageContainer get(String requestUrl, ImageView view, int defaultImageResId, int errorImageResId) {
        return get(requestUrl, getImageListener(view, defaultImageResId, errorImageResId), 720, 480);
    }

    @Override
    public ImageContainer get(String requestUrl, ImageListener imageListener, int maxWidth, int maxHeight) {
        if (requestUrl == null) {
            imageListener.onErrorResponse(new VolleyError("Url is null"));
            return null;
        } else {
            return super.get(requestUrl, imageListener, maxWidth, maxHeight);
        }
    }

}
